<%-- 
    Document   : mudarPermissao
    Created on : 10/10/2011, 20:44:44
    Author     : maury
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="DAO.PrivilegioDAO"%>
<%@page import="Model.Privilegio"%>
<%@page import="DAO.UsuarioDAO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Exceptions.PrivilegioInsuficienteException"%>
<%@page import="Model.Usuario"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file = "autenticacaoAdministrador.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sistema Controle de Reservas</title>
    </head>
    <body>
        <div id="message">${message}</div>
        <h1>Resultados mudar privilégio usuários:</h1>
        Usuários encontrados:
        <hr>
        <table border="1">
            <tr>
                <th>Login</th>
                <th>E-mail</th>
                <th>Privilégio</th>
                <th>Status</th>
                <th>Ação</th>                
            </tr>
            <c:forEach var="usuario" items="${usuarios}">
            <form method="post" action="MainAccessServlet" accept-charset="iso-8859-1,utf-8">
                <input type="hidden" value="${usuario.login}" name="login"/>
                <input type="hidden" value="mudarPermissao" name="cmd"/>
                <tr>
                    <td>${usuario.login}</td>
                    <td>${usuario.email}</td>
                    <td>
                        <select name="privilegio">
                        <c:forEach var="privilegio" items="${privilegios}">
                            <c:if test="${privilegio.id == usuario.privilegio.id}">
                                <option value="${privilegio.id}" selected>${privilegio.nome}</option>
                            </c:if>
                            <c:if test="${privilegio.id != usuario.privilegio.id}">
                                <option value="${privilegio.id}">${privilegio.nome}</option>
                            </c:if>
                        </c:forEach>
                        </select>
                    </td>
                    <c:if test="${usuario.bloquear == true}">
                        <td>Bloqueado</td>
                    </c:if>
                    <c:if test="${usuario.bloquear == false}">
                        <td>Desbloqueado</td>
                    </c:if>
                    <td><input type="submit" value="Submeter"/></td>
                </tr>
            </form>
            </c:forEach>
        </table>
        <button type="button" onclick="location.href='menuAdministrador.jsp'">Voltar</button>     
    </body>
</html>
